#pragma once

#include "IShader.h"


class CShader: public IShader
{
public:
	CShader(CGcontext context);
	virtual ~CShader();

	virtual bool Load(const char* filename);
	virtual uint BeginTechnique(const char* name);
	virtual void EndTechnique();
	virtual void BeginPass(uint index);
	virtual void EndPass();

	virtual void SetSamplerTexture(const char* sampler, ITexture* texture);

private:
	struct SPass
	{
		CGpass									cg_pass;
		CGprogram								cg_vertex_program;
		CGprogram								cg_fragment_program;
		IDirect3DVertexShader9*	vertex_shader;
		IDirect3DPixelShader9*	pixel_shader;
	};
	typedef std::vector<SPass> TPassesList;

	struct STechnique
	{
		CGtechnique	cg_technique;
		TPassesList passes;
	};
	typedef std::map<string, STechnique> TTechniquesMap;

private:
	CGcontext					m_CgContext;
	CGeffect					m_CgEffect;
	TTechniquesMap		m_techniques;

	STechnique*				m_technique;	//	active technique
	SPass*						m_pass;				//	active pass
};